//
//  Client.h
//  XXX
//
//  Created by Xiaoshiheng_pro on 2017/2/18.
//  Copyright © 2017年 Xiaoshiheng_pro. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "GCDAsyncSocket.h"
#import "AppDelegate.h"

@protocol ClientDelegate <NSObject>

@optional

///建立连接
- (void)clientSocket:(GCDAsyncSocket *)sock didConnectToHost:(NSString *)host port:(uint16_t)port;
///失去连接
- (void)clientSocketDidDisconnect:(GCDAsyncSocket *)sock withError:(NSError *)err;
///收到消息
- (void)clientSocket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag;
///发送消息成功
-(void)clientSocket:(GCDAsyncSocket *)sock didWriteDataWithTag:(long)tag;



@end
@interface Client : NSObject

+ (instancetype)ClientInit;
//客户端socket
@property (nonatomic) GCDAsyncSocket *clinetSocke;

@property (weak, nonatomic) id<ClientDelegate> delegate;

- (void)startConnectToHost:(NSString *)serverUrl;

@end
